package 网络编程.Text;

import javax.imageio.plugins.tiff.BaselineTIFFTagSet;
import javax.swing.*;
import java.io.*;
import java.net.Socket;

public class TCPText5 {
    public static void main(String[] args) throws IOException {
        //客户端:将本地文件上传到服务器,并接收服务器的反馈
        //服务端:接收客户端上传的文件,上传完毕给于反馈

        Socket socket=new Socket("127.0.0.1",10006);
        //读取本地文件
        BufferedInputStream bf=new BufferedInputStream(new FileInputStream("D:\\idea2022\\day.com.qiezi\\day_13\\src\\斗地主_控制台版\\d7ce4dff7044790bc3a8cbe84ab0c38.jpg"));
        BufferedOutputStream bf1=new BufferedOutputStream(socket.getOutputStream());

        byte [] bytes=new byte[1024];
        int a;
        while ((a=bf.read(bytes))!=-1){
            //写入到服务器
            bf1.write(bytes,0,a);
        }
            //结束标记
        socket.shutdownOutput();

        //接收反馈数据
       BufferedReader bor=new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line= bor.readLine();
        System.out.println(line);

        //释放资源
        socket.close();
    }
}
